<?php
/*
 * 搜索引擎相关
 * Created on 2012-9-6
 * Creater :cnluckylee
 * Creater mail:cnlucklee@gmail.com
 */
  class search extends CI_Controller{
	public function __construct(){
		parent::__construct();

		$this->load->model('search_model');
		$this->load->helper('url');
		$this->load->library('session');
		$this->load->library('Tools');
	}

	/*按搜索引擎查看*/
	public function showsearch()
	{

		$header['title'] = '搜索引擎';
		$header['location1'] = '搜索引擎';
		$header['location2'] = '搜索引擎';


		$tmp_sdate = $this->input->post("search_sdate");
		if($tmp_sdate)
		{
			$search_sdate = $tmp_sdate;
			$search_edate = htmlspecialchars($this->input->post("search_edate")?$this->input->post("search_edate"):date('Y-m-d'));
			$search_day = -1;
		}else{
			$search_day = intval($this->input->get("search_day")?$this->input->get("search_day"):0);
			$search_sdate = htmlspecialchars($this->input->post("search_sdate")?$this->input->post("search_sdate"):date('Y-m-d',strtotime("-".$search_day." day")));
			if($search_day == 1)
			{
				$search_edate = $search_sdate;
			}else{
				$search_edate = htmlspecialchars($this->input->post("search_edate")?$this->input->post("search_edate"):date('Y-m-d'));
			}
		}
		$data= $this->search_model->showSearch($search_sdate,$search_edate);
		$data['search_sdate'] = $search_sdate;
		$data['search_edate'] = $search_edate;
		$data['search_day'] = $search_day;
 		$this->load->view('main/header',$header);
 		$this->load->view('main/search/search',$data);
 		$this->load->view('main/footer');
	}
	/*按关键词分类查看*/
	public function showkeyword()
	{
		$header['title'] = '关键字';
		$header['location1'] = '搜索引擎';
		$header['location2'] = '关键字';
		$tmp_sdate = $this->input->post("search_sdate");
		if($tmp_sdate)
		{
			$search_sdate = $tmp_sdate;
			$search_edate = htmlspecialchars($this->input->post("search_edate")?$this->input->post("search_edate"):date('Y-m-d'));
			$search_day = -1;
		}else{
			$search_day = intval($this->input->get("search_day")?$this->input->get("search_day"):0);
			$search_sdate = htmlspecialchars($this->input->post("search_sdate")?$this->input->post("search_sdate"):date('Y-m-d',strtotime("-".$search_day." day")));
			$search_edate = htmlspecialchars($this->input->post("search_edate")?$this->input->post("search_edate"):date('Y-m-d'));
		}
		$data= $this->search_model->showKeyword($search_sdate,$search_edate);
		$data['search_sdate'] = $search_sdate;
		$data['search_edate'] = $search_edate;
		$data['search_day'] = $search_day;

 		$this->load->view('main/header',$header);
 		$this->load->view('main/search/keyword',$data);
 		$this->load->view('main/footer');
	}
  }
?>
